/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author edgar
 */
@Entity
@Table(name = "notas_credito_detalle")
@NamedQueries({
    @NamedQuery(name = "NotasCreditoDetalle.findAll", query = "SELECT n FROM NotasCreditoDetalle n"),
    @NamedQuery(name = "NotasCreditoDetalle.findByNroNota", query = "SELECT n FROM NotasCreditoDetalle n WHERE n.notasCreditoDetallePK.nroNota = :nroNota"),
    @NamedQuery(name = "NotasCreditoDetalle.findByNroFactura", query = "SELECT n FROM NotasCreditoDetalle n WHERE n.notasCreditoDetallePK.nroFactura = :nroFactura"),
    @NamedQuery(name = "NotasCreditoDetalle.findByNroLinea", query = "SELECT n FROM NotasCreditoDetalle n WHERE n.notasCreditoDetallePK.nroLinea = :nroLinea"),
    @NamedQuery(name = "NotasCreditoDetalle.findByCantidad", query = "SELECT n FROM NotasCreditoDetalle n WHERE n.cantidad = :cantidad")})
public class NotasCreditoDetalle implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected NotasCreditoDetallePK notasCreditoDetallePK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cantidad")
    private Float cantidad;
    @JoinColumns({
        @JoinColumn(name = "nro_nota", referencedColumnName = "nro_nota", insertable = false, updatable = false),
        @JoinColumn(name = "nro_factura", referencedColumnName = "nro_factura", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private NotasCreditoCabecera notasCreditoCabecera;
    @JoinColumn(name = "cod_articulo", referencedColumnName = "cod_articulo")
    @ManyToOne
    private Articulos codArticulo;

    public NotasCreditoDetalle() {
    }

    public NotasCreditoDetalle(NotasCreditoDetallePK notasCreditoDetallePK) {
        this.notasCreditoDetallePK = notasCreditoDetallePK;
    }

    public NotasCreditoDetalle(int nroNota, int nroFactura, int nroLinea) {
        this.notasCreditoDetallePK = new NotasCreditoDetallePK(nroNota, nroFactura, nroLinea);
    }

    public NotasCreditoDetallePK getNotasCreditoDetallePK() {
        return notasCreditoDetallePK;
    }

    public void setNotasCreditoDetallePK(NotasCreditoDetallePK notasCreditoDetallePK) {
        this.notasCreditoDetallePK = notasCreditoDetallePK;
    }

    public Float getCantidad() {
        return cantidad;
    }

    public void setCantidad(Float cantidad) {
        this.cantidad = cantidad;
    }

    public NotasCreditoCabecera getNotasCreditoCabecera() {
        return notasCreditoCabecera;
    }

    public void setNotasCreditoCabecera(NotasCreditoCabecera notasCreditoCabecera) {
        this.notasCreditoCabecera = notasCreditoCabecera;
    }

    public Articulos getCodArticulo() {
        return codArticulo;
    }

    public void setCodArticulo(Articulos codArticulo) {
        this.codArticulo = codArticulo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (notasCreditoDetallePK != null ? notasCreditoDetallePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NotasCreditoDetalle)) {
            return false;
        }
        NotasCreditoDetalle other = (NotasCreditoDetalle) object;
        if ((this.notasCreditoDetallePK == null && other.notasCreditoDetallePK != null) || (this.notasCreditoDetallePK != null && !this.notasCreditoDetallePK.equals(other.notasCreditoDetallePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.NotasCreditoDetalle[ notasCreditoDetallePK=" + notasCreditoDetallePK + " ]";
    }
    
}
